
export function setRingOpt(opts = {}, name) {
	return {
		color: opts && opts.color ? opts.color : ['#F47D99', '#6FA9FF', '#B59CFE', '#87E7B4', '#DDF474', '#3CA272',
			'#FC8452', '#9A60B4', '#ea7ccc'
		],

		tooltip: {
			trigger: 'item',
			show: false
		},
		legend: {
			show: true,
			orient: 'vertical',
			top: 'center',
			right: '20',
			icon: 'circle'
		},

		series: [
			{
				name: name,
				type: 'pie',
				// radius: ['50%', '90%'],
				radius: opts.type == 'pie' ? '90%' : ['40%', '70%'],
				center: ['90', '50%'],
				label: {
					show: false,
					position: 'center',
					formatter: function (lable) {
						let text = lable.data.name;
						if (text && text.indexOf('(')) {
							text = text.split('(')[0];
						}
						return [
							`{d|${lable.data.value}}{d|%}`,
							`{b|${text && text.length > 6 ? text.slice(0, 5) + '...' : text}}`
						].join('\n');
					},

					rich: {
						d: {
							fontSize: '18',
							fontWeight: 'bold',
							lineHeight: '22'
						},
						b: {
							fontSize: '12',
							color: '#999999'
						},

					}
				},
				itemStyle: {
					borderColor: '#fff',
					borderWidth: 2
				},
				emphasis: {
					label: {
						show: opts.type == 'pie' ? false : true,
						// position: 'center',
						color: '#333',
						// fontSize: '30',

					},
				},
				labelLine: {
					show: false
				},
				data: opts.data

			}
		]
	};
}

export function setPieOpt(opts = {}, name) {
	return {
		color: opts && opts.color ? opts.color : ['#F47D99', '#6FA9FF', '#B59CFE', '#87E7B4', '#DDF474', '#3CA272',
			'#FC8452', '#9A60B4', '#ea7ccc'
		],

		tooltip: {
			trigger: 'item',
			show: true,
			confine: true,
			textStyle:{ 
				textShadowBlur:1
			},
			// position: ['40%', '30%'],
			formatter: function (lable) {
				console.log('formatter', lable);

				return [
					`{d|${lable.data.name}}`,
					`{b|数量:${lable.data.value}}`,
					`{b|占比:${lable.data.ratio}}{b|%}`
				].join('\n');
			},

		},
		legend: {
			show: true,
			orient: 'vertical',
			top: 'center',
			right: '20',
			icon: 'circle'
		},
		title: {
			text: opts.subtext || '',
			subtext: opts.title || '合同总数',
			left: '100',
			top: '43%',
			padding: [0, 0],
			// backgroundColor:'#ccc',
			textAlign: 'center',
			width: '400',
			lineHeight: 20,
			itemGap: 0,
			textStyle: {
				color: '#333',
				fontSize: 18,
				align: 'center',
			},
			subtextStyle: {
				color: '#999999',
				fontSize: 12,
				align: 'center',
				lineHeight: 20,
			},
		},

		series: [
			{
				name: name,
				type: 'pie',
				// radius: ['50%', '90%'],
				radius: opts.type == 'pie' ? '90%' : ['40%', '70%'],
				center: ['100', '50%'],
				label: {
					show: false,

				},
				itemStyle: {
					borderColor: '#fff',
					borderWidth: 2
				},
				emphasis: {
					show: false,
					label: {
						show: false,
						color: '#333',
						// fontSize: '30',

					},
				},
				labelLine: {
					show: false
				},
				data: opts.data

			}
		]
	};
}

export function setProgressPieOpt(opts = {}) {
	return {
		color: ['#0091ff', '#DCF0FF'],

		tooltip: {
			show: false
		},
		legend: {
			show: false
		},
		title: {
			show:false,
		},

		series: [
			{
				type: 'pie',
				silent:true,
				hoverAnimation: false,
				animation: false,
				radius: ['70%', '90%'],
				center: ['50%', '50%'],
				itemStyle: {
					color: '#DCF0FF',
				},
				label: {
					show: false,
				},
				data: [100],
			},
			{
				type: 'pie',
				hoverAnimation: false,
				avoidLabelOverlap: false,
				radius: ['70%', '90%'],
				center: ['50%', '50%'],
				itemStyle: {
					color: '#DCF0FF',
				},
				data: [
					{ 
						value: Number(opts.data || 0),
						itemStyle: { color: '#0091ff', borderRadius: '50%' },
						label: {
							position: 'center',
							fontSize:14,
							color:'#333',
							// fontWeight:'bold', 
							padding:[4,0,0,0],
							formatter: (res)=>{ 
								return res.value.toFixed(1) + '%';
							}
						},
					},
					{
						value: 100 - (opts.data || 0),
						itemStyle: {color: '#DCF0FF', opacity: 0, borderRadius: '50%' },
						label: { show: false },
					},
				],
			},
		]
	};
}
